package com.stox.client.ui.javafx.chartingy.util;

import java.util.Comparator;

import javafx.scene.Node;

import com.stox.client.ui.javafx.chartingy.model.plot.Plot;

public class PlotIndexComparator implements Comparator<Node> {

	@Override
	public int compare(Node o1, Node o2) {
		if(null == o1 && null != o2){
			return -1;
		}else if(null != o1 && null == o2){
			return 1;
		}else if(o1 != null && o2 != null){
			if(o1 instanceof Plot && o2 instanceof Plot){
				Plot<?,?> node1 = (Plot<?,?>)o1;
				Plot<?,?> node2 = (Plot<?,?>)o2;
				return node1.getIndex() > node2.getIndex() ? 1 : 
					(node1.getIndex() < node2.getIndex() ? -1 : 0);
			}
		}
		return 0;
	}
	
}
